local skynet     = require "skynet"
local cjson      = require "cjson"
local datacenter = require "skynet.datacenter"
local max_client = 60000
local id_service = require "id_service"

require "functions"

skynet.start(function()
    skynet.error("start server")

    if not skynet.getenv "daemon" then
        local console = skynet.newservice("console")
    end
    skynet.newservice("debug_console", 8000)

    skynet.newservice("roommgr")

    skynet.newservice("cache")

    local innerwatchdog = skynet.newservice("innerwatchdog")

    skynet.call(innerwatchdog, "lua", "start", {
        port = 7777,
        maxclient = max_client,
        nodelay = true,
    })

    -- login server
    local loginserver = skynet.newservice("logind", LOGIN_PORT)

    local watchdog = skynet.newservice("watchdog", SERVERNAME, loginserver)
    skynet.call(watchdog, "lua", "start", {
        port = GATE_PORT,
        maxclient = max_client,
        nodelay = true,
    })
    skynet.exit()
end)
